/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Fragment, useRef} from 'react';
import {Dimensions, Button} from 'react-native';
import IJKPlayer from './IJKPlayer';

const {width: D_WIDTH, height: D_HEIGHT} = Dimensions.get('window');

const App = () => {
    let videoRef;
    const _onInfo = infoCode => {
        console.log('infoCode:', infoCode);
    };
    const _onError = errorCode => {
        console.log('errorCode:', errorCode);
    };

    const _onReceiveRatioHW = ratioHW => {
        console.log('ratioHW:', ratioHW);
    };

    const _onReceiveDuration = duration => {
        console.log('duration:', duration);
    };
    const _onPrepared = () => {
        console.log('onPrepared in App');
    };
    const _onClick = () => {
        console.log(videoRef);
        videoRef.pause();
    };
    return (
        <Fragment>
            <IJKPlayer
                ref={ref => videoRef = ref}
                url={'rtmp://202.69.69.180:443/webcast/bshdlive-pc'}
                style={{width: D_WIDTH, height: 200}}
                onPrepared={_onPrepared}
                onInfo={_onInfo}
                onError={_onError}
                onReceiveRatioHW={_onReceiveRatioHW}
                onReceiveDuration={_onReceiveDuration}
            />
            <Button onPress={_onClick} title={'button'}/>
        </Fragment>
    );
};

export default App;


